package yl.hs.bmipfull.controllers.chart;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yl.hs.bmipfull.controllers.ControllerBase;
import yl.hs.bmipfull.service.chart.IFinanceChatService;
import yl.hs.bmipfull.viewmodels.WebResult;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author 谢东
 * @apiNote
 * @since 2022-03-17 10:21 创建
 */
@Api(value = "图表中心-生产web接口",tags = "图表中心-财务")
@RestController
@RequestMapping(value = "/api/FinanceChat")
public class FinanceChatServiceController extends ControllerBase {
    @Autowired
    IFinanceChatService financeChatService;
    @ApiOperation(value = "获取未审核发货单", notes = "获取未审核发货单")
    @RequestMapping(value = "/ProductShipOrderNotApproved",method = RequestMethod.GET)
    public WebResult getProductShipOrderNotApproved(){
        return  success("查询成功",financeChatService.getProductShipOrderNotApproved());
    }

    @ApiOperation(value = "获取未审核入库单", notes = "获取未审核入库单")
    @RequestMapping(value = "/PurchaseReceiptNotApproved",method = RequestMethod.GET)
    public WebResult getPurchaseReceiptNotApproved(){
        return  success("查询成功",financeChatService.getPurchaseReceiptNotApproved());
    }

    @ApiOperation(value = "获取结算应收", notes = "获取结算应收")
    @RequestMapping(value = "/SettleAccountReceivable",method = RequestMethod.GET)
    public WebResult getSettleAccountReceivable(){
        return  success("查询成功",financeChatService.getSettleAccountReceivable());
    }

    @ApiOperation(value = "获取结算应付", notes = "获取结算应付")
    @RequestMapping(value = "/SettlementPayable",method = RequestMethod.GET)
    public WebResult getSettlementPayable(){
        return  success("查询成功",financeChatService.getSettlementPayable());
    }

    @ApiOperation(value = "获取其他费用金额合计", notes = "获取其他费用金额合计")
    @RequestMapping(value = "/getSumOtherAmount/{dateType}",method = RequestMethod.GET)
    public WebResult getSumOtherAmount(@ApiParam(value = "时间类型") @PathVariable(required = false) int dateType){
        var data = financeChatService.getSumOtherAmount(dateType);
        return  success("查询成功",data.divide(BigDecimal.valueOf(10000)).setScale(2,RoundingMode.HALF_UP));
    }
    @ApiOperation(value = "获取收付款信息", notes = "获取收付款信息")
    @RequestMapping(value = "/SumTradeAmountByDate/{tradeType}/{dateType}",method = RequestMethod.GET)
    public WebResult getSumTradeAmountByDate(@ApiParam(value = "时间类型") @PathVariable int tradeType,
                                         @ApiParam(value = "产品编号") @PathVariable(required = false) int dateType){
        var sumTradeAmountByDate = financeChatService.getSumTradeAmountByDate(tradeType,dateType);
        BigDecimal data=sumTradeAmountByDate;
        if(tradeType==0){
            var sumOtherAmount = financeChatService.getSumOtherAmount(dateType);
            data=sumTradeAmountByDate.add(sumOtherAmount);
        }
        return  success("查询成功",data.divide(BigDecimal.valueOf(10000)).setScale(2,RoundingMode.HALF_UP));
    }

    @ApiOperation(value = "获取当前用户的代收款信息")
    @GetMapping("/current_user/collection_amount")
    public WebResult getCurrentUserCollectionAmount(){
    return success("ok",financeChatService.getCurrentUserCollectionAmount());
    }
    @ApiOperation(value = "审核应收", notes = "审核应收")
    @RequestMapping(value = "/ExamineQuantity",method = RequestMethod.GET)
    public WebResult getExamineQuantity(){
        return  success("查询成功",financeChatService.getExamineQuantity());
    }

    @ApiOperation(value = "审核应付", notes = "审核应付")
    @RequestMapping(value = "/ExamineNetWeight",method = RequestMethod.GET)
    public WebResult getExamineNetWeight(){
        return  success("查询成功",financeChatService.getExamineNetWeight());
    }

    @ApiOperation(value = "财务应收/实收（柱状图、收款比例折线）", notes = "财务应收/实收（柱状图、收款比例折线）")
    @RequestMapping(value = "/ReceivableAndNetReceiptChart",method = RequestMethod.GET)
    public WebResult getReceivableAndNetReceiptChart(){
        return  success("查询成功",financeChatService.getReceivableAndNetReceiptChart());
    }
    @ApiOperation(value = "产品类别：财务应付/实付（柱状图、付款比例折线）", notes = "产品类别：财务应付/实付（柱状图、付款比例折线）")
    @RequestMapping(value = "/ActualPaymentPayableChart",method = RequestMethod.GET)
    public WebResult getActualPaymentPayableChart(){
        return  success("查询成功",financeChatService.getActualPaymentPayableChart());
    }
}
